from manger import db
from marshmallow import Schema, fields, post_load

class LastDate(db.Model):
    __tablename__ = 'last_date'
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.String)


class LastDateSchema(Schema):
    id = fields.Integer()
    date = fields.String()
    @post_load  # 反序列化成一个对象，给schema的一个方法加上post_load装饰器
    def post_load(self, data, **kwargs):
        return LastDate(**data)